package com.winchain.chainbill.bill.biz.repurchase.service.impl;

import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.persistence.annotation.Pagination;
import com.shell.bee.persistence.model.PageLimit;
import com.shell.framework.utils.CommonDataUtil;
import com.shell.framework.utils.SysDateUtil;
import com.winchain.chainbill.bill.base.dao.CbRecDao;
import com.winchain.chainbill.bill.base.po.CbRpur;
import com.winchain.chainbill.bill.base.service.CbRpurService;
import com.winchain.chainbill.bill.biz.query.vo.CbRecQueryVo;
import com.winchain.chainbill.bill.biz.query.vo.CbRecVo;
import com.winchain.chainbill.bill.biz.repurchase.service.BillRpurQueryService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("billRpurQueryService")
public class BillRpurQueryServiceImpl implements BillRpurQueryService {
	@Autowired
	CbRecDao cbRecDao;
	@Autowired
	CbRpurService cbRpurService;

	@Pagination
	public List<CbRecVo> selectBillForRpurByPage(PageLimit limit, CbRecQueryVo recordQueryVo) {
		recordQueryVo.setHldrId(CommonDataUtil.getCurEntId());
		if (StringUtil.notEmpty(recordQueryVo.getBillCode())) {
			recordQueryVo.setBillCode(StringUtil.getParameterLike(recordQueryVo.getBillCode()));
		}
		String[] billStates = { "S012" };
		recordQueryVo.setBillStates(billStates);

		recordQueryVo.setCurrentDate(SysDateUtil.getSystemDate());

		List<CbRecVo> bills = this.cbRecDao.selectBillForRpur(recordQueryVo);

		return bills;
	}

	@Pagination
	public List<CbRecVo> selectBillForRpurNotInvoiceByPage(PageLimit limit, CbRecQueryVo recordQueryVo) {
		recordQueryVo.setHldrId(CommonDataUtil.getCurEntId());
		if (StringUtil.notEmpty(recordQueryVo.getBillCode())) {
			recordQueryVo.setBillCode(StringUtil.getParameterLike(recordQueryVo.getBillCode()));
		}
		String[] billStates = { "S012" };
		recordQueryVo.setBillStates(billStates);

		recordQueryVo.setCurrentDate(SysDateUtil.getSystemDate());

		List<CbRecVo> bills = this.cbRecDao.selectBillForRpurNotInvoice(recordQueryVo);
		return bills;
	}

	@Pagination
	public List<CbRecVo> selectBillForRpurPmtByPage(PageLimit limit, CbRecQueryVo recordQueryVo) {
		recordQueryVo.setFinId(CommonDataUtil.getCurEntId());
		if (StringUtil.notEmpty(recordQueryVo.getBillCode())) {
			recordQueryVo.setBillCode(StringUtil.getParameterLike(recordQueryVo.getBillCode()));
		}
		if (StringUtil.notEmpty(recordQueryVo.getBuyerNm())) {
			recordQueryVo.setBillCode(StringUtil.getParameterLike(recordQueryVo.getBuyerNm()));
		}
		String[] billStates = { "S014", "S031" };

		recordQueryVo.setBillStates(billStates);
		List<CbRecVo> bills = this.cbRecDao.selectBillForRpurPaid(recordQueryVo);

		return bills;
	}

	public List<CbRpur> selectRpurByBillId(String billId) {
		return null;
	}
}
